﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Vit.SchemaExplorer
{
    [Serializable]
    public abstract class ColumnSchemaBase : SchemaObjectBase
    {
        public string ParameteredName 
        {
            get
            {
                return this.Schema.Database.SchemaProvider.BuildParameterName(this.Name);
            }
        }
        public string OriginalParameteredName
        {
            get
            {
                return this.Schema.Database.SchemaProvider.BuildOriginalParameterName(this.Name);
            }
        }

        public bool AllowDBNull { get; set; }
        public DbType DataType
        {
            get
            {
                return this.Schema.Database.SchemaProvider.ToDbType(this.NativeType);
            }
        }

        public string NativeType { get; set; }
        public byte? Precision { get; set; }
        public int? Scale { get; set; }
        public int? Size { get; set; }
        public bool IsUnique { get; set; }
        public Type SystemType        
        {
            get
            {
                return this.Schema.Database.SchemaProvider.ToSystemType(this.NativeType, AllowDBNull);
            }
        }


        public int Order { get; set; }
    }
}
